import request from './request'

// 员工相关API接口

export interface Employee {
  id: number
  employee_no: string
  name: string
  position: string
  department_id: number
  phone?: string
  email?: string
  created_at?: string
  updated_at?: string
}

export interface EmployeeListResponse {
  items: Employee[]
  total: number
  page: number
  size: number
}

/**
 * 获取员工列表
 */
export const getEmployees = (params?: {
  page?: number
  size?: number
  name?: string
  employee_no?: string
  department_id?: number
}): Promise<EmployeeListResponse> => {
  return request.get('/employees/', { params })
}

/**
 * 创建员工
 */
export const createEmployee = (data: Partial<Employee>): Promise<Employee> => {
  return request.post('/employees/', data)
}

/**
 * 更新员工
 */
export const updateEmployee = (id: number, data: Partial<Employee>): Promise<Employee> => {
  return request.put(`/employees/${id}`, data)
}

/**
 * 删除员工
 */
export const deleteEmployee = (id: number): Promise<void> => {
  return request.delete(`/employees/${id}`)
}
